<?php
/**
 * mongodb记录日志
 *
 * 功能详细说明
 * @author: yanxs <541139655@qq.com>
 * @version: 1.0
 * @date: 2019/8/22
 */

namespace App\Services\Common\Log;


use Illuminate\Support\Facades\DB;

class Mongo implements LogInterface
{
    protected $table ;

    public function __construct()
    {
        //默认做异常日志
        $this->table = config('common.log.default_table');
    }

    /**
     * 指定存储的collection
     * @param $collection 指定存储的集合名称
     */
    public function setCollection($collection)
    {
        $this->table = $collection;
    }
    /**
     * 记录日志到Mongodb数据库
     * @param $data
     */


    public function record($data)
    {
        // TODO: Implement record() method.
        $connection = DB::connection("mongodb")->table($this->table);
  //      echo '<pre>';
  //      print_r($data);exit;
        $connection->insert($data);
    }
}
